package bsts.controller;

import java.util.HashMap;

import bsts.model.User;
import bsts.exception.InvalidAccessException;

public class UserController {

	private IOController ioController;
	private HashMap<String, User> users = new HashMap<String, User>();

	public UserController() {
		ioController = new IOController();
		users = ioController.RetrieveUsers();
	}

	public User verifyUser(String username, String password)
			throws InvalidAccessException {
		if (users.get(username) != null
				&& users.get(username).getPassword().equals(password)) {
			return users.get(username);
		} else {
			throw new InvalidAccessException("Wrong username or password.");
		}

	}

	/*
	 * public boolean verifyUser(String userId, String password) {
	 * ArrayList<User> users = i.RetrieveUsers();
	 * 
	 * for (User user : users) { if (user.getUserId().equals(userId)) { if
	 * (user.getPassword().equals(password)) { return true; } } } return false;
	 * }
	 * 
	 * public UserRole getUserRole(String userId, String password) {
	 * ArrayList<User> users = i.RetrieveUsers();
	 * 
	 * for (User user : users) { if (user.getUserId().equals(userId)) { if
	 * (user.getPassword().equals(password)) { return user.getUserRole(); } } }
	 * return null; }
	 */

}
